import request from "@/utils/request";
import config from "@/config";
// const baseUrl = config.baseUrl;
/**
 * 微信登录
 * @param {*} source pub miniapp
 * @param {*} code
 * @returns
 */
export function wxLogin(source, data) {
	return request({
		url: `/oauth/wx/login/miniapp`,
		headers: {
			isToken: false,
		},
		method: "post",
		data: data
	});
}
// 新用户绑定
export function setNewUser(data,token) {
	return request({
		url: `/pw/user/bindAvatar`,
		headers: {
			isToken: false,
		},
		header: {
			Authorization: "Bearer " + token,
		},
		method: "post",
		data: data
	});
}
/**
 * 微信绑定
 * @param {*} source 微信绑定
 * @param {*} code
 * @returns
 */
export function wxRegister(source, code) {
	return request({
		url: `/oauth/wx/register/${source}/${code}`,
		headers: {
			isToken: true,
		},
		method: "post",
	});
}

/**
 * 微信SDK
 * @returns
 */
export function signature(data) {
	return request({
		url: `/wx/mp/signature`,
		headers: {
			isToken: false,
		},
		method: "get",
		params: {
			url: window.location?.origin
		},
	});
}